package com.blog.cloud.api.dto;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import java.io.Serial;
import java.io.Serializable;

@Getter
@Setter
@Accessors(chain = true)
public class UserRegisterDTO implements Serializable {
    @Serial
    private static final long serialVersionUID = 8898076456286007981L;

    @NotBlank(message = "用户名不能为空")
    @Length(min = 2, max = 8, message = "用户名长度必须在2至8位之间")
    private String username;

    @NotBlank(message = "密码不能为空")
    @Length(min = 8, max = 30, message = "密码长度不能小于8")
    private String password;

    @NotBlank(message = "手机号不能为空")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机格式不正确")
    private String mobile;

    @NotBlank(message = "验证码不能为空")
    private String code;

}

// 关于数据校验的使用参考 SpringBoot 官方文档： https://docs.spring.io/spring-boot/reference/io/validation.html